<?php
	class productOption
	{	
		function show_all_product_option()
		{
			$data = new database();		
			$sql="select * from tblproductOption";
			$data->SetQuery($sql);
			$table = $data->LoadAllRow();
			$data->disconnect();
			return $table;	
		}
		function show_product_option_by_product($productID)
		{
			$data = new database();		
			$sql="	select * 
					from tblproductOption, tblproduct 
					where tblproductOption.productID = tblproduct.productID 
					and tblproductOption.productID='{$productID}' 
					order by position ASC" ;
			
			$data->SetQuery($sql);
			$table = $data->LoadAllRow();
			$data->disconnect();
			return $table;	
		}
		function show_product_option_by_voteID($voteID)
		{
			$data = new database();		
			$sql="	select * 
					from tblproductOption, tblproductVote 
					where tblproductOption.optionID = tblproductVote.optionID 
					and tblproductVote.voteID='{$voteID}'";
			
			$data->SetQuery($sql);
			$table = $data->LoadOneRow();
			$data->disconnect();
			return $table;	
		}
		
		function update($productID,$title,$position,$optionID)
		{
			
			$sql ="UPDATE tblproductOption 
				   SET title ='$title',position=$position
				   WHERE productID = $productID AND optionID=$optionID";
			echo $sql;
			$data = new database();
			$data->SetQuery($sql);
			$data->Query();
			$data->disconnect();
		}
	}
?>